Skip to content

feat(jollity-worker): draw the Daily Dollar scratch card on the host's gesture and mask - #52

Draft
HadiKhai wants to merge 2 commits into
mainfrom
feat/jollity-worker-scratch-card
Draft

HadiKhai wants to merge 2 commits into
mainfrom
feat/jollity-worker-scratch-card

Conversation

@HadiKhai

@HadiKhai HadiKhai commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What it does

The Jollity worker draws a Daily Dollar scratch card itself, on the host's renderer:

  • The ticket is a keyed Gesture whose pan reports where the finger is, over the prize and the foil. The foil sits in a Box that carries a Mask hiding it where the finger went. The card is built from general nodes only, so a foil drawn by another kind of node can take the picture's place under the same mask.
  • The mask follows the pan, so the host draws each stroke of the finger into it as a 52-point line with round ends, in the frame of the touch. A lone press leaves a dot.
  • The host paces the pan's moves. The worker answers only the newest move it holds with an empty ExtendMask, a few bytes each way and never a tree. It keeps the points it hears, so a tree that redraws the ticket (after a scroll, say) keeps the strokes.
  • The mask names a cleared share of 550 thousandths with the action dds.reveal. The host sends it when the strokes clear 55% of the foil with the finger up. A tree without the foil then shows the prize, then the result card. The worker keeps no threshold of its own and ignores a repeat.
  • The ticket takes the Daily Dollar ticket's size and pictures for the platform the host reports (iOS 290 x 380, Android 309 x 400).

The first commit adds newestOnly (src/newest-only.ts), which answers only the newest gesture move. The worker slider draft uses it too and carries the same commit, so whichever of the two lands second drops it on rebase.

How it looks

On an iPhone simulator: a slow stroke, a fast stroke and a lone-press dot clear the foil under the finger, then strokes across until the foil goes on a lift and the prize shows, then the result card. The pauses between touches are shortened, and the reveal and the result play at real speed. The small blue circles are the simulator showing where the finger is.

scratch-card-dot-strokes-and-result-iphone.mp4

The same worker on an Android emulator, with the same touches.

scratch-card-dot-strokes-and-result-android.mp4

How it was tested

  • The worker built from this head ran on an iPhone simulator and an Android emulator, each with a host built from the paired trinity-user-agents changes (feat(renderer): a mask any node can carry, with a cleared share the host reports trinity-user-agents#2284, #2285 and #2286). On both, strokes and a lone-press dot clear the foil under the finger, the prize shows after a lift that clears enough of the foil, and the result card follows.
  • Unit tests cover the card's nodes (the mask on the box around the foil, its follow and clearedShare), the empty ExtendMask answers, the reveal only on the host's action, a repeat reveal ignored, the redraw of a half-scratched ticket with its strokes and dot, and the platform looks.
  • Locally, against a truapi build that carries the new nodes, the worker's tests pass (1147 of 1150) apart from three. The truapi wire schema pin in hostStack.test.ts moves only with a truapi release. A chain reading test and the hung poll test time out on a heavily loaded machine and pass when run again.
  • On that truapi build, typecheck reports one error, in src/host.ts: registerRoom passes a roomId that the newer chat request type no longer has. It comes from the chat API on trinity-user-agents main, not from the card.

What it needs from trinity-user-agents

It needs renderer pieces that no truapi release carries yet: the generic Gesture node with its event payload (positions in hundredths of a logical pixel), the Mask modifier with follow and clearedShare, and the ExtendMask update. The paired draft pull requests on paritytech/trinity-user-agents are in progress.

Checks that can't pass yet

The worker pins the published @parity/truapi at ^0.32.0, which has none of those pieces. So the Jollity and Previewnet checks stay red until a truapi release carries the gesture and mask nodes: typecheck fails on the new exports (extendMask, maskStroke, decodeGestureEvent, the Gesture node and the Mask modifier), and the scratch card tests fail for the same reason. The schema pin in hostStack.test.ts moves with the truapi bump that brings them.

What's not done

  • The ticket's outcome and its claim are stand-ins: the outcome alternates, and a win's first claim fails to show the retry. Tying the card to the Daily Dollar draw and the real claim is still to do.
  • Only a DD_SCRATCH=worker build posts the card (see apps/jollity-worker/README.md). The default build posts none.

src/index.ts is also changed by #51 in other places. The two merge cleanly, and whichever lands second rebases.

…holds

A host that paces a keyed pan sends at most one move a display frame, and
none while the last is unanswered. newestOnly answers the newest move once
the ones already delivered have been read, so a slow worker answers where
the finger is now instead of working through a backlog. The scratch card and
the worker slider both answer their moves through it.
…s gesture and mask

The worker draws the ticket itself through the renderer: a keyed Gesture
whose pan reports the finger's location, over the prize and the foil. The
foil sits in a Box carrying a Mask that hides it where the finger went. The
mask follows the pan, so the host draws each stroke as a 52-point line with
round ends in the frame of the touch, and a lone press leaves a dot. The host
paces the pan's moves, and the worker answers only the newest one it holds
with an empty ExtendMask, never a tree. It keeps the points it hears, so a
tree that redraws the ticket keeps the strokes.

The mask names a cleared share of 550 thousandths with the action
dds.reveal: the host sends it when the strokes clear 55% of the foil with the
finger up, and a tree without the foil shows the prize, then the result card.
The worker keeps no threshold of its own and ignores a repeat.

The ticket takes the existing Daily Dollar ticket's size and pictures on the
platform the host reports (iOS 290 x 380, Android 309 x 400). Its outcome and
claim are stand-ins, and only a DD_SCRATCH=worker build posts it.
@HadiKhai
HadiKhai force-pushed the feat/jollity-worker-scratch-card branch from 829bd2a to 20ef2d7 Compare November 24, 2026 11:24
@HadiKhai HadiKhai changed the title feat(jollity-worker): draw the Daily Dollar scratch card on the host's gesture node feat(jollity-worker): draw the Daily Dollar scratch card on the host's gesture and mask Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant